home *** CD-ROM | disk | FTP | other *** search
- unit Unit1;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ShellAPI, StdCtrls;
-
- const
- wm_AppBarMessage = wm_User;
-
- type
- TForm1 = class(TForm)
- Memo1: TMemo;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- private
- { Private declarations }
- abd: TAppBarData;
- function GetRequestRect: TRect;
- procedure WMAppBarMessage(var Msg: TMessage); message wm_AppBarMessage;
- procedure WMWindowPosChanged(var Msg: TWMWindowPosMsg); message WM_WindowPosChanged;
- procedure WMMoving(var Msg: TMessage); message WM_Moving;
- procedure WMSizing(var Msg: TMessage); message WM_Sizing;
- procedure WMExitSizeMove(var Msg: TMessage); message WM_ExitSizeMove;
- property RequestRect: TRect read GetRequestRect;
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- var
- F: TextFile;
-
- {$R *.DFM}
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- // fill the AppBarData data structure
- abd.cbSize := sizeof(abd);
- abd.hWnd := Handle;
- abd.uCallBackMessage := wm_AppBarMessage;
- abd.uEdge := ABE_BOTTOM;
- abd.rc := RequestRect;
- abd.lParam := 0;
- SHAppBarMessage(ABM_NEW, abd);
-
- // set the initial size and position
- SHAppBarMessage(ABM_QUERYPOS, abd);
- abd.rc.Top := abd.rc.Bottom - Height;
- SHAppBarMessage(ABM_SETPOS, abd);
- SetBounds(abd.rc.Left, abd.rc.Bottom - Height, abd.rc.Right-abd.rc.Left, Height);
- end;
-
- procedure TForm1.FormDestroy(Sender: TObject);
- begin
- SHAppBarMessage(ABM_REMOVE, abd);
- end;
-
- procedure TForm1.FormShow(Sender: TObject);
- begin
- ShowWindow(Application.Handle, SW_HIDE);
- Memo1.Text := DateTimeToStr(Now);
- end;
-
- procedure TForm1.FormActivate(Sender: TObject);
- begin
- SHAppBarMessage(ABM_ACTIVATE, abd);
- end;
-
- function TForm1.GetRequestRect: TRect;
- begin
- // set the requested Rect
- Result.Left := 0;
- Result.Top := Screen.Height - Height;
- Result.Right := Screen.Width;
- Result.Bottom := Screen.Height;
- end;
-
- procedure TForm1.WMAppBarMessage(var Msg: TMessage);
- begin
- // hide when fullscreen apps are displayed
- if Msg.wParam = ABN_FULLSCREENAPP then
- if Msg.lParam <> 0 then Hide else Show;
-
- if Msg.wParam = ABN_POSCHANGED then
- begin
- // fill the AppBarData data structure
- abd.rc := RequestRect;
- SHAppBarMessage(ABM_QUERYPOS, abd);
- abd.rc.Top := abd.rc.Bottom - Height;
- SHAppBarMessage(ABM_SETPOS, abd);
- SetBounds(abd.rc.Left, abd.rc.Bottom - Height, abd.rc.Right-abd.rc.Left, Height);
- end;
- end;
-
- procedure TForm1.WMWindowPosChanged(var Msg: TWMWindowPosMsg);
- begin
- // must send this message to maintain correct Z-order
- SHAppBarMessage(ABM_WINDOWPOSCHANGED, abd);
- inherited;
- end;
-
- procedure TForm1.WMMoving(var Msg: TMessage);
- begin
- PRect(Msg.lParam)^ := abd.rc;
- inherited;
- end;
-
- procedure TForm1.WMSizing(var Msg: TMessage);
- begin
- PRect(Msg.lParam)^ := Rect(Left, PRect(Msg.lParam)^.Top, Width, PRect(Msg.lParam)^.Bottom);
- inherited;
- end;
-
- procedure TForm1.WMExitSizeMove(var Msg: TMessage);
- begin
- abd.rc.Top := abd.rc.Bottom - Height;
- SetBounds(abd.rc.Left, abd.rc.Top, abd.rc.Right-abd.rc.Left, abd.rc.Bottom-abd.rc.Top);
- SHAppBarMessage(ABM_SETPOS, abd);
- inherited;
- end;
-
- initialization
- AssignFile(F, 'c:\temp\debug.log');
- Rewrite(F);
- finalization
- CloseFile(F);
- end.
-